package com.wc.alorithm_luogu.P2347;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/25 16:39
 * @description 砝码称重
 * https://www.luogu.com.cn/problem/P2347
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 10;
    static int[] a = new int[N];
    static int[] fm = new int[]{0, 1, 2, 3, 5, 10, 20};

    public static void main(String[] args) {
        HashSet<Integer> set = new HashSet<>();
        set.add(0);
        for (int i = 1; i <= 6; i++) {
            a[i] = sc.nextInt();
        }

        for (int i = 1; i <= 6; i++) {
            int curFm = fm[i];
            for (int j = 1; j <= a[i]; j++) {
                HashSet<Integer> tmp = new HashSet<>();
                for (int w : set) {
                    tmp.add(w);
                    tmp.add(w + curFm);
                    // 如果可以放到天平的两边，加上下面这个
//                    tmp.add(Math.abs(w - curFm));
                }
                set = tmp;
            }
        }
        out.println("Total=" + (set.size() - 1));
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
